<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<style>
  figure {
    display: grid;
    border-radius: 1rem;
    overflow: hidden;
    cursor: pointer;
  }

  figure>* {
    grid-area: 1/1;
    transition: .4s;
  }

  figure figcaption {
    display: grid;
    align-items: end;
    font-family: sans-serif;
    font-size: 2.3rem;
    font-weight: bold;
    color: #0000;
    padding: .75rem;
    background: var(--c, #0009);
    clip-path: inset(0 var(--_i, 100%) 0 0);
    -webkit-mask:
      linear-gradient(#000 0 0),
      linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    -webkit-mask-clip: text, padding-box;
  }

  figure:hover figcaption {
    --_i: 0%;
  }

  figure:hover img {
    transform: scale(1.2);
  }

  @supports not (-webkit-mask-clip: text) {
    figure figcaption {
      -webkit-mask: none;
      color: #fff;
    }
  }

  body {
    margin: 0;
    min-height: 100vh;
    display: grid;
    grid-auto-flow: column;
    place-content: center;
    background: #425a52;
  }
</style>

<body>
  <figure>
    <img src="https://picsum.photos/id/287/250/300" alt="Mountains">
    <figcaption>The Day</figcaption>
  </figure>
  <figure style="--c:#fff5">
    <img src="https://picsum.photos/id/475/250/300" alt="Mountains">
    <figcaption>The Night</figcaption>
  </figure>
</body>

</html>